<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"><meta name="referrer" content="no-referrer" />
    <title>编辑公告页面</title>
    <script src="js/jquery-1.11.0.min.js"></script>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/style.min.css" rel="stylesheet">
    <style>
        .left-side {
            position: fixed;
            top: 0;
            bottom: 0;
            z-index: 5;
            display: block;
            width: 240px;
            font-weight: 500;
        }
        .card{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 700px;
            border-radius: 5px;
        }
        .submenu >ul{
            display: none;
        }
        .open>ul{
            display: block;
        }
    </style>
    <script>
        $(function () {
            console.log("进入头部");
            $(".header").load("adminHeadHtml");
            var id = window.sessionStorage.getItem("id");
            console.log("编号为：" + id);
            $.ajax({
                url: "/getEditNotice",
                type: "POST",
                data: JSON.stringify({"id": id}),
                contentType: "application/json",
                dataType: "json",
                success: function (obj) {
                    console.log("---------");
                    console.log(obj);
                    console.log("---------");
                    $("#editnoticeName").attr("value",obj.title);
                    $("#editnoticeContent").attr("value",obj.con);
                }
            });
        });
        function edit() {
            var id = window.sessionStorage.getItem("id");
            console.log("编号为：" + id);
            var title = $("#editnoticeName").val();
            var con = $("#editnoticeContent").val();
            var date = $("#editnoticeDate").val();
            $.ajax({
                url:"editNotice",
                type:"POST",
                contentType: "application/json",//划重点
                // async:false,//同步，默认异步
                dataType:"json",
                data: JSON.stringify({"id": id,"title":title,"con":con,"date":date}),//划重点
                success: function (data) {
                    // console.log("编辑请求执行完成！");
                    // window.location.href = "adminNotice";
                    if (confirm("修改成功！")){
                        window.location.href = "adminNotice";
                    }
                }
            });
        }
    </script>
    <script>
        $(function () {
            $('.submenu').mouseover(function(){
                $(this).addClass('open');
            }).mouseout(function(){
                $(this).removeClass('open');
            });
        })
    </script>
</head>
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside class="lyear-layout-sidebar">
            <!-- logo -->
            <div id="logo" class="sidebar-header">
                <h1 style="text-align: center;color: #33cabb;">Spider</h1>
            </div>
            <div class="lyear-layout-sidebar-scroll">
                <nav class="sidebar-main">
                    <ul class="nav nav-drawer" style="list-style: none">
                        <li class="nav-item active"><a href="/adminNotice"><i class="mdi mdi-home"></i>公告管理</a></li>
                        <li class="nav-item active"><a href="/toFindAllUsers"><i class="mdi mdi-home"></i>用户管理</a></li>
                        <li class="nav-item active"><a href="/adminComment"><i class="mdi mdi-home"></i>查看反馈</a></li>
                        <li class="nav-item active submenu"><a href="#"><i class="mdi mdi-home"></i>个人中心</a>
                            <ul class="nav nav-drawer">
                                <li class="nav-item active"><a href="/toSelf">&nbsp&nbsp&nbsp&nbsp<i
                                        class="mdi mdi-step-forward"></i>信息编辑</a></li>
                            </ul>
                        </li>
                    </ul>
                </nav>
            </div>
        </aside>
        <!--End 左侧导航-->
        <!--头部信息-->
        <div class="header"></div>
        <!--End 头部信息-->
        <!-- 主题内容 -->
        <!--页面主要内容 table table-striped table-hover-->
        <main class="lyear-layout-content">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div id="spiderSea">
                                <div action="" id="form">
                                    标题：<input class="inputText" id="editnoticeName" name="editnoticeName" style="width: 350px;height: 20px"><br><br><br>
                                    内容：<input class="inputText" id="editnoticeContent" name="editnoticeContent" style="width: 350px;height: 40px"><br><br><br>
                                    日期：<input type="datetime-local" id="editnoticeDate" class="editnoticeDate" name="editnoticeDate" style="width: 350px;height: 20px"><br><br><br>
                                    <input type="submit" class="button" value="修改" onclick="edit()">
<!--                                    <input type="submit" class="start" value="修改" style="height: 30px; float: right;">-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
        <!--End 页面主要内容-->
    </div>
</div>
</body>
</html>